package com.surendra.rectangle.unittests;


public class Rectangle {
	private Point p1, p2;
	
	Rectangle(Point p1, Point p2) {
		this.p1 = p1;
		this.p2 = p2;
	}
	/**
	 * 
	 * @return an area of an rectangle
	 * points P1 and P2 each have x and y co-ordinates respectively
	 * which are subtracted to get the absolute length and width
	 * of a rectangle
	 */
	public Double getArea() {
		return Math.abs((p2.x - p1.x) * (p2.y - p1.y));
	}
	/**
	 * 
	 * @returns diagonal of a rectangle using pythagores theorem
	 */
	public Double getDiagonal() {
		return Math.sqrt(Math.pow((p2.x - p1.x), 2) + Math.pow((p2.y - p1.y), 2));
	}
}
